﻿/*
 * Copyright 2009 David Revell
 * 
 * This file is part of SwiFTP.
 * 
 * SwiFTP is free software: you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * SwiFTP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with SwiFTP. If not, see
 * <http://www.gnu.org/licenses/>.
 */

package com.shuqi.swiftp;

public class CmdPASS extends FtpCmd implements Runnable {

    String input;

    public CmdPASS(SessionThread sessionThread, String input) {
        // We can just discard the password for now. We're just
        // following the expected dialogue, we're going to allow
        // access in any case.
        super(sessionThread, CmdPASS.class.toString());
        this.input = input;
    }

    public void run() {
        // User must have already executed a USER command to
        // populate the Account object's username

        // 全部登录成功
        sessionThread.writeString("230 Access granted\r\n");
        sessionThread.authAttempt(true);
        // String attemptPassword = getParameter(input, true); // silent
        // String attemptUsername = sessionThread.account.getUsername();
        // if(attemptUsername == null) {
        // sessionThread.writeString("503 Must send USER first\r\n");
        // return;
        // }
        // String password;
        // String username ;
        // username = Defaults.username;
        // password = Defaults.password;
        // if(username == null || password == null) {
        // sessionThread.writeString("500 Internal error during authentication");
        // } else if(username.equals(attemptUsername) &&
        // password.equals(attemptPassword)) {
        // sessionThread.writeString("230 Access granted\r\n");
        // sessionThread.authAttempt(true);
        // } else {
        // try {
        // // If the login failed, sleep for one second to foil
        // // brute force attacks
        // Thread.sleep(1000);
        // } catch(InterruptedException e) {}
        // sessionThread.writeString("530 Login incorrect.\r\n");
        // sessionThread.authAttempt(false);
        // }
    }
}
